using System.ComponentModel;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Altairis.Web.UI.WebControls {

    [ToolboxData("<{0}:MessageView runat=server />")]
    public class MessageView : System.Web.UI.WebControls.View {

        [Localizable(true), Bindable(true)]
        public string Message {
            get { return (string)this.ViewState["Message"]; }
            set { this.ViewState["Message"] = value; }
        }

        public void FormatMessage(params object[] args) {
            this.Message = string.Format(this.Message, args);
        }

        public void Show() {
            (this.Parent as MultiView).SetActiveView(this);
        }

        protected override void Render(HtmlTextWriter writer) {
            this.Controls.AddAt(0, new LiteralControl(this.Message));
            base.Render(writer);
        }
    }
}